home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.app;
-
- import com.extensibility.rock.Screen;
- import com.extensibility.util.Evaluator;
- import com.extensibility.util.FilteredEnumerator;
- import com.extensibility.xml.URI;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Frame;
- import java.awt.Point;
- import java.awt.Window;
- import java.awt.event.WindowListener;
- import java.io.IOException;
- import java.text.DateFormat;
- import java.util.Date;
- import java.util.Enumeration;
- import java.util.EventObject;
- import java.util.Hashtable;
- import java.util.Vector;
- import javax.swing.JFrame;
- import javax.swing.SwingUtilities;
-
- public class Desktop extends Screen {
- protected static Vector documents = new Vector();
- protected static Vector windows = new Vector();
- protected static HelpWindow helpWindow;
- protected static Splash splash;
- protected static JFrame welcome;
- protected static BaseWindow frontWindow;
- protected static Hashtable docWinCounter = new Hashtable();
- static WindowListener windowListener = new 4();
-
- public static final BaseDocument getMostRecentDocument(Class var0) {
- for(int var1 = documents.size() - 1; var1 >= 0; --var1) {
- if (var0.isInstance(documents.elementAt(var1))) {
- return (BaseDocument)documents.elementAt(var1);
- }
- }
-
- return null;
- }
-
- public static BaseWindow getFrontDocWindow() {
- return frontWindow;
- }
-
- public static final void activateDocument(BaseDocument var0) {
- if (var0 != null) {
- int var1 = windows.size();
- int var2 = 1;
-
- while(var2 < windows.size() - 1) {
- BaseWindow var3 = (BaseWindow)windows.elementAt(var2);
- BaseDocument var4 = var3.getDocument();
- if (var4 != null && var4 != var0) {
- ((Window)var3).toBack();
- if (windows.removeElement(var3)) {
- windows.addElement(var3);
- }
-
- --var1;
- if (var1 == 0) {
- return;
- }
- } else {
- ++var2;
- }
- }
-
- }
- }
-
- public static final BaseDocument getDocument(URI var0) {
- for(int var1 = 0; var1 < documents.size(); ++var1) {
- if (((BaseDocument)documents.elementAt(var1)).getURI().equals(var0)) {
- return (BaseDocument)documents.elementAt(var1);
- }
- }
-
- return null;
- }
-
- public static final Enumeration getDocuments() {
- return documents.elements();
- }
-
- public static final Vector getWindows() {
- return windows;
- }
-
- public static int getDefaultDocWidth(BaseDocument var0) {
- return Screen.DOC_WIDTH;
- }
-
- public static int getDefaultDocHeight(BaseDocument var0) {
- return Screen.DOC_HEIGHT;
- }
-
- public static int getDefaultDocLeft(BaseDocument var0) {
- return Screen.DOC_LEFT;
- }
-
- protected static int getOffset() {
- int var0 = 0;
-
- while(true) {
- BaseWindow var1 = null;
-
- for(int var2 = 0; var1 == null && var2 < windows.size(); ++var2) {
- BaseWindow var3 = (BaseWindow)windows.elementAt(var2);
- int var10001 = Screen.DOC_LEFT + var0;
- if (((Component)var3).getLocation().x == var10001) {
- var1 = var3;
- }
- }
-
- if (var1 == null) {
- return var0;
- }
-
- var0 += 16;
- }
- }
-
- protected static Point getNextDocLoc() {
- int var0 = getOffset();
- return new Point(Screen.DOC_LEFT + var0, Screen.DOC_TOP + var0);
- }
-
- public static void positionNewWindow(BaseWindow var0) {
- BaseDocument var1 = var0.getDocument();
- Point var2 = getNextDocLoc();
- Dimension var3 = new Dimension(var1.getDefaultDocWidth(), var1.getDefaultDocHeight() - var2.y);
- if (var2.x + var3.width > Screen.getScreenSize().width) {
- var3.width = Screen.getScreenSize().width - var2.x - 8;
- }
-
- if (var2.y + var3.height > Screen.getScreenSize().height) {
- var3.height = Screen.getScreenSize().height - var2.y - 8;
- }
-
- ((Component)var0).setLocation(var2);
- var0.setSize(var3.width, var3.height);
- }
-
- public static void showNewWindow(BaseWindow var0, boolean var1) {
- BaseDocument var2 = var0.getDocument();
- if (!var1) {
- Integer var3 = (Integer)docWinCounter.get(var2);
- int var4 = var3 + 1;
- ((Frame)var0).setTitle(String.valueOf(String.valueOf(((Frame)var0).getTitle()).concat(String.valueOf(':'))).concat(String.valueOf(var4)));
- docWinCounter.put(var2, new Integer(var4));
- }
-
- ((Component)var0).setVisible(true);
- if (var1) {
- splashCleanup();
- docWinCounter.put(var2, new Integer(1));
- }
-
- }
-
- public static HelpWindow createHelpWindow(String var0) {
- String var1 = BaseApplication.getPreferences().getBrowserPath();
- if (!BaseApplication.getPreferences().getExternalHelpBrowser()) {
- var1 = null;
- }
-
- if (var1 != null) {
- try {
- String var10 = UI.getHelpURI(var0);
- Runtime var3 = Runtime.getRuntime();
- StringBuffer var4 = new StringBuffer("");
- int var5 = 0;
-
- for(int var6 = var10.length(); var5 < var6; ++var5) {
- char var7 = var10.charAt(var5);
- if (var7 != ' ') {
- var4.append(var7);
- } else {
- var4.append("%20");
- }
- }
-
- String[] var11 = new String[]{String.valueOf(String.valueOf('"').concat(String.valueOf(var1))).concat(String.valueOf('"')), var4.toString()};
- var3.exec(var11);
- Object var8 = null;
- return (HelpWindow)var8;
- } catch (IOException var9) {
- }
- }
-
- if (helpWindow == null) {
- helpWindow = new HelpWindow(var0);
- String var2 = UI.getString("help.item.index.htm");
- if (var2.startsWith("#")) {
- var2 = "index.html";
- }
-
- helpWindow.setHome(var2);
- helpWindow.addWindowListener(new 1());
- helpWindow.setLocation(Screen.getScreenSize().width - 600 - 3, Screen.TOP_GAP);
- helpWindow.setSize(600, Screen.DOC_HEIGHT);
- helpWindow.setVisible(true);
- } else {
- helpWindow.toFront();
- helpWindow.setVisible(true);
- helpWindow.showPage(var0);
- }
-
- return helpWindow;
- }
-
- public static Splash createAboutWindow() {
- Splash var0 = createSplash();
- ((Window)var0).toFront();
- return var0;
- }
-
- public static void splashCleanup() {
- if (splash != null) {
- splash.setVisible(false);
- splash.dispose();
- }
-
- }
-
- public static Splash createSplash() {
- if (splash == null) {
- splash = new Splash();
- splash.addWindowListener(new 2());
- updateSplash(splash);
- }
-
- splash.show();
- return splash;
- }
-
- public static void updateSplash(Splash var0) {
- splash = var0;
- String var1 = BaseApplication.getPreference("ESB");
- String var2 = BaseApplication.getPreference("KKB");
- String var3 = BaseApplication.getPreference("CAB");
- Date var4 = BaseApplication.getExpiration();
- String var5 = BaseApplication.getApplication().getVersion();
- String var6 = null;
- if (BaseApplication.isLaunchLimited()) {
- var6 = UI.getString("splash.limit", (new Integer(BaseApplication.getLaunchesLeft())).toString());
- } else if (var4 != null) {
- DateFormat var7 = DateFormat.getDateInstance(2);
- String var8 = var7.format(var4);
- var6 = UI.getString("splash.expire", var8);
- }
-
- splash.setInfo(var1, var2, var3, var4, var5, var6);
- }
-
- public static void ensureWindow() {
- if (windows.size() == 0) {
- welcome.show();
- }
-
- }
-
- public static JFrame createWelcome(boolean var0) {
- if (welcome == null) {
- welcome = BaseApplication.getApplication().createWelcome();
- }
-
- if (var0) {
- welcome.show();
- }
-
- return welcome;
- }
-
- public static JFrame getWelcome() {
- return welcome;
- }
-
- public static BaseWindow findWindow(Evaluator var0) {
- Enumeration var1 = windows.elements();
-
- while(var1.hasMoreElements()) {
- BaseWindow var2 = (BaseWindow)var1.nextElement();
- if (var0.isMatch(var2)) {
- return var2;
- }
- }
-
- return null;
- }
-
- public static Enumeration getWindowsOfDocument(BaseDocument var0) {
- return new FilteredEnumerator(windows.elements(), new 3(var0));
- }
-
- public static boolean isLastWindowOfDocument(BaseWindow var0) {
- BaseDocument var1 = var0.getDocument();
- Enumeration var2 = windows.elements();
-
- while(var2.hasMoreElements()) {
- BaseWindow var3 = (BaseWindow)var2.nextElement();
- if (var3 != var0 && var3.getDocument() == var1) {
- return false;
- }
- }
-
- return true;
- }
-
- public static boolean isLastDocument(BaseDocument var0) {
- return documents.size() == 1 && documents.elements().nextElement() == var0;
- }
-
- public static final WindowListener getWindowListener() {
- return windowListener;
- }
-
- protected static void removeWindow(BaseWindow var0) {
- windows.removeElement(var0);
- }
-
- protected static void addWindow(BaseWindow var0) {
- windows.addElement(var0);
- }
-
- protected static void windowListChanged() {
- for(int var0 = 0; var0 < windows.size(); ++var0) {
- ((BaseWindow)windows.elementAt(var0)).fillWindowsMenu();
- }
-
- }
-
- protected static void closingDocument(BaseDocument var0) {
- documents.removeElementAt(documents.indexOf(var0));
- }
-
- protected static void openningDocument(BaseDocument var0) {
- documents.addElement(var0);
- }
-
- public static Frame getDialogParent(EventObject var0) {
- Component var1 = null;
- if (var0 != null) {
- var1 = var0.getSource() instanceof Component ? (Component)var0.getSource() : null;
- }
-
- return getDialogParent(var1);
- }
-
- public static Frame getDialogParent(Component var0) {
- if (var0 == null) {
- var0 = getFrontDocWindow();
- }
-
- if (var0 == null && getWindows().size() > 0) {
- var0 = (Component)getWindows().firstElement();
- }
-
- if (var0 == null) {
- var0 = welcome;
- }
-
- if (var0 == null) {
- return null;
- } else if (var0 instanceof Frame) {
- if (!((Component)var0).isVisible()) {
- ((Component)var0).setVisible(true);
- }
-
- return (Frame)var0;
- } else {
- Window var1 = SwingUtilities.windowForComponent((Component)var0);
- if (var1 instanceof Frame) {
- if (!((Component)var1).isVisible()) {
- ((Component)var1).setVisible(true);
- }
-
- return (Frame)var1;
- } else {
- return getDialogParent((Component)null);
- }
- }
- }
- }
-